# -*- make -*-

# C sources and rule to make objects
SOURCES = callbacks.c context.c tree.c
OBJS = $(SOURCES:%.c=%.o)
HEADERS = headers.h structs.h

# name of executable
EXE = parse reconstitute xpath reader
EXE_OBJS = $(EXE:%=%.o)

# names of compilers
CC = gcc

# flags to pass to compilers
CFLAGS = -g -O2 -Wall $(shell xml2-config --cflags) -DDEBUG

# libraries to link to
C_LIBS = $(shell xml2-config --libs) -lsqlite3 

all: $(EXE)

# make executable with objects
$(EXE) : % : %.c $(OBJS)
	$(CC) $(CFLAGS) -c $< -o $*.o
	$(CC) $(C_LIBS) $(OBJS) $*.o -o $@ 

# objects depend on source files and headers
%.o: %.c %.h $(HEADERS)
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(EXE) $(OBJS) $(EXE_OBJS)
